home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / abc / FAQ / files < prev    next >
Encoding:
Text File  |  1994-04-01  |  3.0 KB  |  66 lines  |  [TEXT/R*ch]

  1. WHY DOES ABC HAVE NO FILE HANDLING?
  2.  
  3. One part of the philosophy of ABC is that the language should not
  4. reflect architectural details of computers. Consider Pascal: there are
  5. a number of features that are there because of features of computer
  6. architecture:
  7.  
  8.     that functions can only return 'small' values (because
  9.         values are returned in registers);
  10.     that there is such a thing as a maximum integer value;
  11.     the existence of pointers.
  12.  
  13. The same thing is true of C, and many other languages.
  14.  
  15. Our opinion is that these architectural features only get in the way
  16. of the true task of programming: not being able to return a
  17. complicated structure is a pain; you want to count the number of times
  18. something happens: getting overflow doesn't help you achieve this.
  19.  
  20. As a consequence we designed ABC from a 'task oriented' point of view:
  21. first try to work out what people are trying to achieve when
  22. programming, then design a language that supports that, and only
  23. *then* see if we could implement it. No maximum integers.
  24.  
  25. Now, files reflect an architectural feature of computers: that there
  26. is two-level storage. If you want to keep a structure after your
  27. program has run you must convert the structure into a form acceptable
  28. for external storage (i.e. files), and write it out. Then the next
  29. time you run your program, you have to reread that file and recreate
  30. the internal structure. This has as little to do with true programming
  31. as checking for integer overflow does: it is purely administrative work.
  32.  
  33. In ABC, the position is as follows: there is no two level storage.
  34. Your global variables do not disappear after you log out: when you
  35. start up again, there they are exactly as you left them.
  36.  
  37. Put in another way: variables *are* files.
  38. Put in another way: there is no difference between files and variables.
  39.  
  40. The advantages: one concept instead of two; much less to learn; the
  41. language doesn't need to have separate data-types and commands to
  42. manipulate files; the programmer's life is far easier; ABC's 'files'
  43. are much more powerful than traditional files (you have random access
  44. to elements, even associative access, for instance).
  45.  
  46. On the other hand, we realise that in the 'real world' people have
  47. files that haven't been produced by ABC. Just in the same way that
  48. word-processors let you import ASCII files, or sometimes even files
  49. produced by another word processor, there is a facility to let you
  50. convert operating system files to ABC files. The facility is described
  51. in the helpfile: it is the -i option.
  52.  
  53. For instance:
  54.  
  55.     abc -i autoexec < autoexec.bat
  56.  
  57. will convert the MSDOS autexec.bat file to an ABC global called
  58. 'autoexec'. The global is created as a table of texts, one line to an
  59. entry.
  60.  
  61. We have considered adding system programming additions to ABC to allow
  62. you to directly access non-ABC things from within ABC, but 1) we are
  63. afraid that people will then think that this is the file-handling
  64. feature of ABC, while in fact the true file-handling feature is far
  65. more powerful, and 2) we haven't had the time :-)
  66.